package com.blackitheima.test1;

public class Student implements Comparable<Student>{
    private String neme;
    private int age;

    public Student() {
    }

    public Student(String neme, int age) {
        this.neme = neme;
        this.age = age;
    }

    public String getNeme() {
        return neme;
    }

    public void setNeme(String neme) {
        this.neme = neme;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "neme='" + neme + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        //初条件
        int result=this.getAge()-o.getAge();
        //次条件
        result=result==0?this.getNeme().compareTo(o.getNeme()):result;
        return result;
    }
}
